<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      var obj = {
        name: "孙悟空",
        age: 18,
        gender: "男",
        address: "花果山",
      };

      // 枚举对象中的属性
      // 使用for ...in 语句
      /**
       * 语法:
       * for(var 变量in 对象){
       * }
       *
       * for..in语句在对象中有几个属性,循环体就会执行几次
       */

      for (var n in obj) {
        console.log("属性名" + n);
        console.log("属性值" + obj[n]);
      }
    </script>
  </head>
  <body></body>
</html>
